package com.qfedu.kbonline.service.impl;

import com.qfedu.kbonline.common.core.CodeCreate;
import com.qfedu.kbonline.common.model.CodeGenModel;
import com.qfedu.kbonline.common.model.DbModel;
import com.qfedu.kbonline.dto.CodeDto;
import com.qfedu.kbonline.service.intf.CodeService;
import com.qfedu.kbonline.vo.R;
import org.springframework.stereotype.Service;

/**
 * @program: CodingsSart
 * @description:
 * @author: ErBa(韩智飞)
 * @create: 2020-09-14 14:42
 */
@Service
public class CodeServiceImpl implements CodeService {
    @Override
    public R create(CodeDto dto) {
        DbModel dbModel=new DbModel(dto.getHost(),dto.getPort(),dto.getDbname(),dto.getUser(),dto.getPass());
        CodeGenModel codeGenModel=new CodeGenModel(dto.getPkname(),dto.getAuthor(),dto.getDes());
        if(CodeCreate.createCode(codeGenModel,dbModel)){
            return R.ok();
        }else {
            return R.fail();
        }
    }
}
